package com.spzx.product.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.domain.vo.CategoryVo;
import com.spzx.product.api.service.RemoteCategoryService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteCategoryFallbackFactory implements FallbackFactory<RemoteCategoryService> {
    @Override
    public RemoteCategoryService create(Throwable cause) {
        return new RemoteCategoryService() {

            @Override
            public R<List<CategoryVo>> getOneCategory(Long parentId, String source) {
                return R.fail("获取全部一级分类失败:" + cause.getMessage());
            }

            @Override
            public R<List<CategoryVo>> getCategoryTree(String source) {
                return R.fail("获取分类树失败:" + cause.getMessage());
            }
        };
    }
}
